blob: 4c7c4e74a9be4e3599e9715cc5acf77c93771440 [file] [log] [blame]
Nicolás Peña Morenocd2c04e2019-05-09 23:24:541<!DOCTYPE html>
2<html>
3<meta charset=utf-8 />
4<div id='div' onclick='delay()'>Click me</div>
5<div id='div2'>No, click me!</div>
6<script src=/resources/testharness.js></script>
7<script src=/resources/testharnessreport.js></script>
8<script src=/resources/testdriver.js></script>
9<script src=/resources/testdriver-vendor.js></script>
10
Nicolás Peña Morenoaa9d7f52019-05-14 22:20:0611<script src=resources/event-timing-test-utils.js></script>
Nicolás Peña Morenocd2c04e2019-05-09 23:24:5412<script>
13 let delayCalled = false;
14 let beforeClick;
15 function delay() {
16 const end = performance.now() + 150;
17 while(performance.now() < end) {}
18 delayCalled = true;
19 }
20 async_test(function(t) {
21 const observer = new PerformanceObserver(t.step_func_done((entryList) => {
Nicolás Peña Morenoaa9d7f52019-05-14 22:20:0622 const entries = entryList.getEntries().filter(e => e.name === 'mousedown');
Nicolás Peña Morenocd2c04e2019-05-09 23:24:5423 // There must only be one click entry: from the clickAndBlockMain() call.
24 assert_equals(entries.length, 1);
25 const entry = entries[0];
26 // This ensures that the entry is exposing timing from the second click, i.e.
27 // the one from the clickAndBlockMain() call.
28 assert_greater_than_equal(entry.processingStart, beforeClick);
Nicolás Peña Morenoaa9d7f52019-05-14 22:20:0629 // Check that the first input entry was also from the second click.
30 const firstInput = performance.getEntriesByType('firstInput');
31 assert_equals(firstInput.length, 1);
32 assert_greater_than_equal(firstInput[0].processingStart, beforeClick);
Nicolás Peña Morenocd2c04e2019-05-09 23:24:5433 }));
Nicolás Peña Morenoaa9d7f52019-05-14 22:20:0634 observer.observe({entryTypes: ['event']});
Nicolás Peña Morenocd2c04e2019-05-09 23:24:5435 document.getElementById('div').click();
36 // Take the timestamp after the programmatic click but before the next click.
37 beforeClick = performance.now();
38 // After the programmatic click, use another input to know when entries have been
39 // dispatched to the PerformanceObserver callback.
40 clickAndBlockMain('div2');
41 }, "Event Timing: events from programmatic click are not observed");
42</script>
43</html>